<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        body, div {
            padding: 0px;
            margin: 0px;
        }
        img {
            vertical-align: middle;
        }

        div.ex {
            width: 240px;
            padding: 20px, 10px;
            border: 5px solid gray;
        }
    </style>
</head>
<body>
    <div>
        <img width="250px" height="250px" src="../image/green.png"/>
    </div>
    <div class="ex">上面的图片是250 px宽。这个元素的总宽度也是250 px。</div>
</body>
</html>